﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace coliseu.BussinessLayer
{
    public class VisitanteBL
    {
        private coliseuEntities cEntities;

        public VisitanteBL()
        {
            cEntities = new coliseuEntities(Properties.Settings.Default.conn_coliseu);
        }

        public List<visitante> selecionar()
        {
            return (from x in cEntities.visitante select x).ToList();
        }

        public List<visitante> selecionar(string nome, string cpf)
        {
            return (from x in cEntities.visitante where x.nome.Contains(nome) && x.CPF.Contains(cpf) select x).ToList();
        }

        public void salvar(visitante b, string tipo)
        {

            if (tipo == "insert")
            {
                cEntities.AddTovisitante(b);
            }
            else
            {
                cEntities.visitante.ApplyCurrentValues(b);
            }
            cEntities.SaveChanges();
        }

        public void excluir(visitante b)
        {
            cEntities.visitante.DeleteObject(b);
            cEntities.SaveChanges();
        }
    }
}
